<template>
    <div class="photoinfo-container">
        <h3>{{ photoinfo.title }}</h3>
        <p class="subtitle">
            <span class="subtitle-title">发表时间:{{ photoinfo.add_time | dateFormat }}</span>
            <span class="subtitle-body">点击:{{ photoinfo.click }}次</span>
        </p>

        <hr>

        <!-- 缩略图区域 -->
         <vue-preview 
         class="imgPrev"
         :slides="list" 
         @close="handleClose"></vue-preview>
        <!-- 内容 -->
        <div class="content" v-html="photoinfo.content"></div>

        <!-- 子组件 -->
        <cmt-box :id="id"></cmt-box>

    </div>
</template>

<script>
import comment from '../subcomps/comment.vue'
export default {
    data() {
        return {
            id: this.$route.params.id,
            photoinfo: {},
            list: []
        }
    },
    created(){
        this.getPhotoInfo()
        this.getThumbs()
    },
    methods: {
        getPhotoInfo(){
            this.$http.get('getimageInfo/' + this.id).then( res => {
                if(res.body.status === 0){
                    this.photoinfo = res.body.message[0]
                }
            })
        },
        getThumbs(){
            this.$http.get('getthumimages/' + this.id).then(res => {
                if(res.body.status === 0){
                    res.body.message.forEach(item => {
                        item.msrc = item.src
                        item.w = 600;
                        item.h = 400;
                    })
                this.list = res.body.message
                }
            })
        },
        handleClose () {
        console.log('close event')
      }
    },
    components: {
        'cmt-box': comment
    }
}
</script>

<style lang="scss">
    .photoinfo-container{
        padding: 3px;
        h3{
            color: #26A2FF;
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
        }
        .subtitle{
            display: flex;
            justify-content: space-between;
            font-size: 13px;
        }
        .content{
            font-size: 13px;
            line-height: 30px;
        }
        .my-gallery{
            margin: 10px;
            padding: 0px;
            figure{ 
                display: inline;
                margin: 0;
            }
            img{
                margin: 6px;
                width: 90px;
                height: 90px;
                box-shadow: 0 0 8px #999;
            }
        }
    }
</style>